package com.decheng.servlet;

import com.decheng.dto.PaginationDTO;
import com.decheng.pojo.Book;
import com.decheng.service.BookService;
import com.decheng.service.impl.BookServiceImpl;
import com.decheng.servlet.base.VIewServlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author 孔德成
 * @Slogan 致敬大师，致敬未来的你
 * @desc 显示主页
 */
public class IndexServlet extends VIewServlet {
    private BookService bookService = new BookServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String currentPage = req.getParameter("currentPage");
        String pageSize = req.getParameter("pageSize");
        PaginationDTO<Book> bp = bookService.showBookList(currentPage, pageSize);
        req.setAttribute("data", bp);
        engine.processTemplate("index", req, resp);
    }
}
